const mongoose = require('mongoose');
// 表规则
var userSchame = new mongoose.Schema({
    username: {
        type: String,
        required: [true, '用户名不能为空']
    },
    password: {
        type: String,
        required: [true, '密码不能为空'],
        trim: true
    },
    age: {
        type: Number,
        min: [18, '年龄不能小于18'],
        max: [100, '年龄不能高于100']
    },
    sex: {
        type: String,
        enum: {
            values: ['男', '女', '保密'],
            message: '请到专门机构鉴定'
        }
    },
    address: {
        type: String
    },
    createTime: {
        type: Date,
        default: Date.now
    }
});

// 创建表
const User = mongoose.model('user', userSchame);

module.exports = User;